package com.antball.data.other;

import java.util.Arrays;

/**
 * 选择排序
 * @Auther: huangsj
 * @Date: 2019/9/18 18:36
 * @Description:
 */
public class SelectSorts {

    public static void main(String[] args) {

        int[] arr = {7, 6, 5, 3, 1, 9, 4};

        System.out.println(Arrays.toString(arr));
        System.out.println("------------------------");
        for (int i = 0; i < arr.length; i++) {
            int minIndex = i;
            for (int j = i; j < arr.length; j++) {
                if (arr[minIndex] > arr[j]) {
                    minIndex = j;
                }
            }
            int temp = arr[minIndex];
            arr[minIndex] = arr[i];
            arr[i] = temp;

            System.out.println(Arrays.toString(arr));
        }
    }

}
